package com.ztom.test.processor

import com.ztom.beans.factory.ConfigurableListableBeanFactory
import com.ztom.beans.factory.support.pojo.PropertyValue
import com.ztom.beans.factory.support.processor.BeanFactoryPostProcessor

/**
 * @author ZhangTao
 */
class CustomBeanFactoryPostProcessor(
    var name: String? = null,
    var field: String? = null,
    var value: Any? = null
) : BeanFactoryPostProcessor {

    override fun postProcessBeanFactory(beanFactory: ConfigurableListableBeanFactory) {
        val beanDefinition = beanFactory.getBeanDefinition(name!!)
        beanDefinition.propertyValues
            .addPropertyValue(PropertyValue(field!!, value!!))
    }
}